﻿@using DBMS.Models
@{
    ViewBag.Title = "Results";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Results</h2>

@{
    List<int> rows = ViewBag.Rows;
    List<Value> values = ViewBag.Values;
    List<Column> columns = ViewBag.Columns;
    
    List<int> columnIds = columns.Select(x => x.Index).ToList();

    int counter = columns.Count;
    
    <table>
    <thead>
    <tr>
    @foreach (Column column in columns)
    {
        <td>@column.Name</td>
    }
    </tr>
    </thead>
    <tbody>
    @foreach (int row in rows)
    {
        <tr>
        @foreach (Value value in values)
        {
            if ((value.RowId == row) && (columnIds.Contains(value.ColumnId)))
            {
                <td>@value.ConcreteValue</td>
            }
        }
        </tr>
    }
    </tbody>
    </table>
}